﻿using IQIGame.Onigao.Game;

namespace IQIGame.Onigao.GamePlay
{
    public class CommonLoadingUIController : ILoadingController
    {
        public uint MaxStore => 1;

        private UILoading uiLoading = null;

        public void Start()
        {
            ManagerCenter.UI.ShowWindowSync<UILoading>();
            this.uiLoading = ManagerCenter.UI.GetEntityUI<UILoading>();
            this.uiLoading.UpdateLoadingProgress(0f);
        }

        public void UpdateProgress(float ratio)
        {
            if (this.uiLoading != null)
                this.uiLoading.UpdateLoadingProgress(ratio);
        }

        public void End()
        {
            if (this.uiLoading != null)
            {
                this.uiLoading.Close();
            }
            uiLoading = null;
        }

        public void OnReset()
        {
            End();
        }
    }
}
